//贷款
import { get_loan, loan_audit } from "@/api/loan";
export default {
  namespaced: true,
  state: {
    page: 1,
    limit: 15,
    status: -1,
    rows: [],
    total: "",
    info: {},
  },
  mutations: {
    toggle: (state, payload) => {
      state.total = payload.total;
      state.rows = payload.rows;
    },
    changeState: (state, payload) => {
      state.status = payload;
    },
    modify: (state, payload) => {
      state.info = payload;
    },
  },
  actions: {
    getLoanList: async ({ commit, state }) => {
      const { page, limit, status } = state;
      console.log({ page, limit, status });
      const data = await get_loan({
        page,
        limit,
        status,
      });
      commit("toggle", data);
    },

    audit: async ({ state }) => {
      const { info } = state;
      console.log(info, "info");
      const { success } = await loan_audit(info);
      return success;
    },
  },
  getters: {},
};
